set(TestPrefix "Test-")
file(GLOB testPaths ./*)
foreach(test ${testPaths})
    if (NOT IS_DIRECTORY  "${test}")
        continue()
    endif ()

    if (NOT EXISTS "${test}/CMakeLists.txt")
        continue()
    endif ()

    cmake_path(GET test STEM name)
    add_subdirectory(${name})
endforeach()

function(CreateTest _RelativePath)
    set(CreatePath "${CMAKE_CURRENT_SOURCE_DIR}/${_RelativePath}")
    if (EXISTS  "${CreatePath}")
        return()
    endif ()

    #    TODO 暂未处理多级目录和现有插件目录情况
    file(MAKE_DIRECTORY "${CreatePath}")

    configure_file(${CMAKE_SOURCE_DIR}/template/TestTemplate/main.cc.in
            ${CreatePath}/main.cc
            @ONLY
    )
    configure_file(${CMAKE_SOURCE_DIR}/template/TestTemplate/CMakeLists.txt.in
            ${CreatePath}/CMakeLists.txt
            @ONLY
    )
endfunction()

CreateTest(config)